package thread;
import java.util.Scanner;
public class demo8 {

        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int q = scanner.nextInt();
            for (int i = 0; i < q; i++) {
                int n = scanner.nextInt();
                int[] arr = new int[n];
                for (int j = 0; j < n; j++) {
                    arr[j] = scanner.nextInt();
                }
                int l = scanner.nextInt();
                int r = scanner.nextInt();
                int zeroCount = 0;
                int sumKnown = 0;
                for (int num : arr) {
                    if (num == 0) {
                        zeroCount++;
                    } else {
                        sumKnown += num;
                    }
                }
                int minSum = sumKnown + zeroCount * l;
                int maxSum = sumKnown + zeroCount * r;
                System.out.println(minSum + " " + maxSum);
            }
        }
    }

